import request from '@/utils/request'

export const authApi = {
  // 检查权限
  checkPermission: (userId, permissionName) => {
    return request.get('/api/auth/check-permission', {
      params: { userId, permissionName }
    })
  },

  // 获取用户权限列表
  getPermissions: (userId) => {
    return request.get('/api/auth/permissions', {
      params: { userId }
    })
  },

  // 检查角色
  checkRole: (userId, roleName) => {
    return request.get('/api/auth/check-role', {
      params: { userId, roleName }
    })
  },

  // 获取用户角色列表
  getRoles: (userId) => {
    return request.get('/api/auth/roles', {
      params: { userId }
    })
  },

  // 用户登录
  login: (username, password) => {
    return request.post('/api/users/login', {
      username,
      passwordHash: password
    })
  },

  // 用户登出
  logout: (userId) => {
    return request.post('/api/users/logout', {
      userId
    })
  },

  // 重置密码
  resetPassword: (username) => {
    return request.post('/api/users/password/reset', {
      username
    })
  },

  // 修改密码
  changePassword: (userId, oldPassword, newPassword) => {
    return request.put('/api/users/password', {
      userId,
      oldPassword,
      newPassword
    })
  },

  // 刷新token
  refreshToken: (refreshToken) => {
    return request.post('/api/users/token/refresh', {
      refreshToken
    })
  }
} 